/*
 * Exploder
 * 
 * Tero Pyylampi (218437), Jussi Tuurinkoski (211594)
 *
 * Abstract base class for all the border elements in the game
 */

#ifndef GAMEBORDER_H
#define GAMEBORDER_H

#include "../GamePhysicObject.h"
#include "../../../../Common.h"

#include "Box2D/Box2D.h"
#include "cocos2d.h"

class GameCamera;

class GameBorder : public GamePhysicObject {
public:
	// default constructor
	GameBorder( b2World *world, cocos2d::CCLayer *layer, GameCamera *camera, float durability );
	// default destructor
	virtual ~GameBorder();

	// default update function
	virtual void update( cocos2d::ccTime dt ) = 0;

	// object takes damage as a result of a collision
	virtual void takeDamage( float damage, b2Body *bodyTakingDamage );
	// break and remove object
	virtual void breakObject() = 0;
	// change to broken sprite
	virtual void changeToBrokenSprite() = 0;

	// get the main type of the object
	virtual PhysicObjectItems getObjectType() = 0;

	// get absolute screen position of the sprite
	virtual cocos2d::CCPoint getObjectScreenPosition();
	// rotate item
	void rotateItem( cocos2d::CCObject *pSender );

protected:
	// pointers to game layer and camera
	cocos2d::CCLayer *mGameLayer;
	GameCamera *mGameCamera;

	// border sprite
	cocos2d::CCSprite *mBorderSprite;
	// broken version
	cocos2d::CCSprite *mBrokenSprite;

	// durability & max durability
	float mMaxDurability;
	float mDurabilityLeft;

	// flags for thread safe
	bool mBrokenSpriteInUse;
	bool mBorderDestroyed;

	// for saving buttons
	cocos2d::CCMenu *mBorderMenu;
	// helper function to create menu items
	void createBorderMenuItems();
};

#endif
